/* ----------------------------------------------------------------------------
* File: user_profile.h
*
* Desc: Declaration of CUserProfile class
*
* Created: 19/02/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _USER_PROFILE_H_
#define _USER_PROFILE_H_

#include "common.h"
#include "include.h"
#include "file_logger.h"

typedef struct user_box_info
{
	user_box_info(): id(0)
	{
		files.clear();
	}

	unsigned int id;
	std::map<unsigned int, file_info*> files;
}user_box_info;


typedef struct user_profile 
{
	user_profile(): username(NULL)
	{
		boxes.clear();
	}

	char *username;
	std::map<unsigned int, user_box_info*> boxes;
}user_profile;


/************************************************************************/
/*	Interface IUserProfile for any user profile							*/
/************************************************************************/
class IUserProfile
{
public:
	virtual ~IUserProfile(){}

	// Read profile
	virtual int ReadProfile() = 0;

	// Get profile info
	virtual const user_profile* GetProfileInfo() const = 0;

	// Get user info
	virtual int GetUserInfo(user_info *uinfo) = 0;
};


/************************************************************************/
/*	CUserProfile class to operate with user profile data				*/
/************************************************************************/
class CUserProfile : public IUserProfile
{
public:
	CUserProfile();
	~CUserProfile();

	// Read profile
	virtual int ReadProfile();

	// Get profile info
	virtual const user_profile* GetProfileInfo() const { return &m_profile; }

	// Get user info
	virtual int GetUserInfo(user_info *uinfo) { return BOX_SERVER_ERROR; }

private:
	user_info m_info;
	user_profile m_profile;
};


/************************************************************************/
/*	CTestUserProfile class for testing									*/
/************************************************************************/
//class CUserBox;
class CTestUserProfile : public IUserProfile
{
public:
	CTestUserProfile(const char *username, CFileLogger *logger);
	~CTestUserProfile();

	// Read profile
	virtual int ReadProfile();

	// Get profile info
	virtual const user_profile* GetProfileInfo() const { return &m_profile; }

	// Get user info
	virtual int GetUserInfo(user_info *uinfo);

private:
	CFileLogger *m_logger;
	user_profile m_profile;
	FILE *m_fp;
};

/************************************************************************/
/*	CUser class to store info about user boxes                          */
/************************************************************************/
//class CUserProfile
//{
//	typedef std::vector<CUserBox*>				VectorUserBoxes;
//	typedef std::vector<CUserBox*>::iterator	VectorUserBoxesIterator;
//public:
//	CUserProfile(CBoxServer *parent, unsigned int id);
//	virtual ~CUserProfile();
//
//	// Read profile from database
//	virtual int ReadProfile();
//	// Get parent
//	CBoxServer* GetParent() const { return m_parent; }
//	// Read property of files in all boxes
//	int ReadBoxesProperty();
//	// Build boxes property
//	int BuildUserInfo(void** data, size_t& size);
//	// Get user info
//	const user_info* GetUserInfo() const { return &m_info; }
//	// Get box by id
//	CUserBox* GetBoxById(size_t id) const;
//
//	// Get logger object
//	ILogger* GetLogger() { return m_logger; }
//
//private:
//	CBoxServer* m_parent;
//	VectorUserBoxes m_list_boxes;
//	user_info m_info;
//	ILogger *m_logger;
//};



/************************************************************************/
/*	CTestUser class - class for testing									*/
/************************************************************************/
//class CTestUserProfile : public CUserProfile
//{
//public:
//	CTestUserProfile(CBoxServer *parent, unsigned int id);
//	~CTestUserProfile();
//
//	// Read profile from file
//	virtual int ReadProfile();
//};

#endif // _USER_PROFILE_H_